import '../../public.dart';

class WalletPendingActionsWidget extends StatelessWidget {
  final UserModel model;

  const WalletPendingActionsWidget({super.key, required this.model});

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(12),
        boxShadow: [
          BoxShadow(
            color: Colors.grey.withValues(alpha: 0.1),
            spreadRadius: 1,
            blurRadius: 3,
            offset: const Offset(0, 1),
          ),
        ],
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 标题
          Padding(
            padding: const EdgeInsets.all(16),
            child: Text(
              'Pending Actions',
              style: TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w600,
                color: Colors.grey[700],
              ),
            ),
          ),

          // 银行账户
          model.bankCardEmpty
              ? GestureDetector(
                  onTap: () async {
                    final isAdd = await RouterHelper.navigator.pushNamed(
                      Routers.addBankCard,
                    );
                    if (isAdd != null && isAdd as bool) {
                      await model.getBankCardList();
                    }
                  },
                  child: _buildPendingItem(
                    'Add default bank account',
                    'Add Bank',
                    Colors.blue,
                  ),
                )
              : const SizedBox(),

          // PIN码
          model.hasPin == false
              ? _buildPendingItem(
                  'You haven\'t PIN yet.',
                  'Add PIN',
                  Colors.blue,
                )
              : const SizedBox(),
        ],
      ),
    );
  }

  // 待处理事项单项
  Widget _buildPendingItem(String title, String actionText, Color actionColor) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
      decoration: BoxDecoration(
        border: Border(top: BorderSide(color: Colors.grey.shade100)),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            title,
            style: const TextStyle(fontSize: 15, color: Color(0xFF323232)),
          ),
          Text(
            actionText,
            style: TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.w500,
              color: actionColor,
            ),
          ),
        ],
      ),
    );
  }
}